// run: $exec < input
#include <iostream>
#include <algorithm>

int main()
{
	int n;
	int min[3], max[3], ans[3];
	std::cin >> n;
	for (int i = 0; i < 3; i++) {
		std::cin >> min[i] >> max[i];
		ans[i] = min[i];
	}

	int sum = ans[0] + ans[1] + ans[2];
	for (int i = 0; i < 3; i++) {
		int t = std::min(max[i] - min[i], n - sum);
		sum += t;
		ans[i] += t;
	}
	for (int i = 0; i < 3; i++)
		std::cout << ans[i] << ' ';
	std::cout << '\n';
}

